package reflectx

import (
	"gitee.com/zhongguo168a/gocodes/datax/schemax"
	"gitee.com/zhongguo168a/gocodes/datax/schemax/basickind"
)

type BasicTypeRef struct {
}

func (f *BasicTypeRef) RefHas(field string) bool {
	switch field {
	case "Kind":
		return true
	}
	return false
}

func (f *BasicTypeRef) RefGet(target IRefObject, BasicType string) (val interface{}, isNil bool) {
	obj := target.(*schemax.BasicType)
	switch BasicType {
	case "Kind":
		return obj.Kind, false
	}
	return nil, true
}

func (f *BasicTypeRef) RefSet(target IRefObject, BasicType string, val interface{}) {
	obj := target.(*schemax.BasicType)
	switch BasicType {
	case "Kind":
		obj.Kind = basickind.Kind(val.(int))
	}
	return
}

func (f *BasicTypeRef) RefNew() IRefObject {
	return &schemax.BasicType{}
}

func (f *BasicTypeRef) RefType() string {
	return "basic"
}
